﻿/*
#**************************************************************************
#  openSIS is a student information system for public and non-public 
#  schools from Open Solutions for Education, Inc. web: www.os4ed.com
#
#  openSIS is  web-based, open source, and comes packed with features that 
#  include student demographic info, scheduling, grade book, attendance, 
#  report cards, eligibility, transcripts, parent portal, 
#  student portal and more.   
#
#  Visit the openSIS web site at http://www.opensis.com to learn more.
#  If you have question regarding this system or the license, please send 
#  an email to info@os4ed.com.
#
#  This program is released under the terms of the GNU General Public License  
#  as  published by the Free Software Foundation, version 2 of the License. 
#  See license.txt.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
#**************************************************************************** 
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Web.UI.WebControls;
using OpenSIS.OpenSISWCFServiceReference;
using OSISDynamicTranslation;

namespace OpenSISStudentListControl
{
    public class StudentListControl
    {

        public void populatedynamicrchk(ref System.Web.UI.WebControls.CheckBoxList chk,int FieldID)
        {
            OpenSISWCFServiceStudentFormLayoutClient vmlDL = new OpenSISWCFServiceStudentFormLayoutClient();
            chk.Items.Clear();
            DataSet ds = null;
            ds = vmlDL.populatedynamicrchk(FieldID);
            vmlDL.Close();
            chk.DataSource = ds.Tables[0];
            chk.DataTextField = "ListItem_name";
            chk.DataValueField = "ListItem_Id";
            chk.DataBind();
        }

        public void populatedynamicrchkStuedntBusiness(ref System.Web.UI.WebControls.CheckBoxList chk, int Extrafielddid)
        {
            IopenSISServiceStudentClient vmlDL = new IopenSISServiceStudentClient();
            chk.Items.Clear();
            DataTable ds = null;
            ds = vmlDL.populatedynamicrchkStudentBusiness(Extrafielddid);
            vmlDL.Close();
            chk.DataSource = ds;
            chk.DataTextField = "ListItem_name";
            chk.DataValueField = "ListItem_Id";
            chk.DataBind();
        }
        public void populatedynamicrbtn(ref System.Web.UI.WebControls.RadioButtonList rbtn, int FieldId)
        {
            OpenSISWCFServiceStudentFormLayoutClient vmlDL1 = new OpenSISWCFServiceStudentFormLayoutClient();
            rbtn.Items.Clear();
            DataSet ds = null;
            ds = vmlDL1.populatedynamicrbtn(FieldId);
            vmlDL1.Close();
            rbtn.DataSource = ds.Tables[0];
            rbtn.DataTextField = "ListItem_name";
            rbtn.DataValueField = "ListItem_Id";
            rbtn.DataBind();
        }

        public void populatedynamicrbtnstudentbusiness(ref System.Web.UI.WebControls.RadioButtonList rbtn, int Extrafielddid)
        {
            IopenSISServiceStudentClient vmlDL1 = new IopenSISServiceStudentClient();
            rbtn.Items.Clear();
            DataTable ds = null;
            ds = vmlDL1.populatedynamicrbtnStudentBusiness(Extrafielddid);
            vmlDL1.Close();
            rbtn.DataSource = ds;
            rbtn.DataTextField = "ListItem_name";
            rbtn.DataValueField = "ListItem_Id";
            rbtn.DataBind();
        }
        public void populatedynamicddl(ref System.Web.UI.WebControls.DropDownList ddl, int FieldId)
        {
            OpenSISWCFServiceStudentFormLayoutClient vmlDL2 = new OpenSISWCFServiceStudentFormLayoutClient();
            ddl.Items.Clear();
            DataSet ds = null;
            ds = vmlDL2.populatedynamicddl(FieldId);
            ddl.DataSource = ds.Tables[0];
            ddl.DataTextField = "ListItem_name";
            ddl.DataValueField = "ListItem_Id";
            ddl.DataBind();
            ddl.Items.Insert(0, new ListItem("Select", "0"));

        }

        public void populatedynamicddlstudentbusiness(ref System.Web.UI.WebControls.DropDownList ddl, int ExtrafieldID)
        {
            IopenSISServiceStudentClient vmlDL2 = new IopenSISServiceStudentClient();
            ddl.Items.Clear();
            DataTable ds = null;
            ds = vmlDL2.populatedynamicddlStudentBusiness(ExtrafieldID);
            ddl.DataSource = ds;
            ddl.DataTextField = "ListItem_name";
            ddl.DataValueField = "ListItem_Id";
            ddl.DataBind();
            ddl.Items.Insert(0, new ListItem("Select", "0"));

        }
        public void PopulateGender(ref System.Web.UI.WebControls.RadioButtonList rdb)
        {
            OpenSISWCFServiceStudentFormLayoutClient vmlDL3 = new OpenSISWCFServiceStudentFormLayoutClient();
            rdb.Items.Clear();
            DataSet ds = null;
            ds = vmlDL3.PopulateGenderSt();
            vmlDL3.Close();
            DynamicTranslation DTL = new DynamicTranslation();
            string langto = System.Web.HttpContext.Current.Session["MLUICulture"].ToString();
            if (System.Web.HttpContext.Current.Session["MLUICulture"].ToString() != "en")
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    string origtext = ds.Tables[0].Rows[i]["gender_nm"].ToString();
                    string trantext = DTL.Translate(origtext, "en", langto);
                    ds.Tables[0].Rows[i]["gender_nm"] = trantext;
                }
            }
            rdb.DataSource = ds.Tables[0];
            rdb.DataTextField = "gender_nm";
            rdb.DataValueField = "gender_id";
            rdb.DataBind();
        }
        public void populateEthnicity(ref System.Web.UI.WebControls.DropDownList ddl,int SchID)
        {
            OpenSISWCFServiceStudentFormLayoutClient vmlDL4 = new OpenSISWCFServiceStudentFormLayoutClient();
            ddl.Items.Clear();
            DataSet ds = null;
            ds = vmlDL4.populateEthnicitySt(SchID);
            vmlDL4.Close();
            DynamicTranslation DTL = new DynamicTranslation();
            string langto = System.Web.HttpContext.Current.Session["MLUICulture"].ToString();
            if (System.Web.HttpContext.Current.Session["MLUICulture"].ToString() != "en")
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    string origtext = ds.Tables[0].Rows[i]["eth_nm"].ToString();
                    string trantext = DTL.Translate(origtext, "en", langto);
                    ds.Tables[0].Rows[i]["eth_nm"] = trantext;
                }
            }
            ddl.DataSource = ds.Tables[0];
            ddl.DataTextField = "eth_nm";
            ddl.DataValueField = "eth_id";
            ddl.DataBind();
            ddl.Items.Insert(0, new ListItem("Select", "0"));
        }
        public void populateLanguage(ref System.Web.UI.WebControls.DropDownList ddl)
        {
            OpenSISWCFServiceStudentFormLayoutClient vmlDL5 = new OpenSISWCFServiceStudentFormLayoutClient();
            ddl.Items.Clear();
            DataSet ds = null;
            ds = vmlDL5.populateLanguageSt();
            vmlDL5.Close();
            ddl.DataSource = ds.Tables[0];
            ddl.DataTextField = "language_nm";
            ddl.DataValueField = "language_id";
            ddl.DataBind();
            ddl.Items.Insert(0, new ListItem("Select", "0"));
        }
        public void populateState(ref System.Web.UI.WebControls.DropDownList ddl)
        {
            OpenSISWCFServiceStudentFormLayoutClient vmlDL6 = new OpenSISWCFServiceStudentFormLayoutClient();
            ddl.Items.Clear();
            DataSet ds = null;
            ds = vmlDL6.populateStateSt();
            vmlDL6.Close();
            ddl.DataSource = ds.Tables[0];
            ddl.DataTextField = "NAME";
            ddl.DataValueField = "IID";
            ddl.DataBind();
            ddl.Items.Insert(0, new ListItem("Select", "0"));
        }
        public void populateCountry(ref System.Web.UI.WebControls.DropDownList ddl)
        {
            OpenSISWCFServiceStudentFormLayoutClient vmlDL7 = new OpenSISWCFServiceStudentFormLayoutClient();
            ddl.Items.Clear();
            DataSet ds = null;
            ds = vmlDL7.populateCountrySt();
            vmlDL7.Close();
            ddl.DataSource = ds.Tables[0];
            ddl.DataTextField = "NAME";
            ddl.DataValueField = "IID";
            ddl.DataBind();
            ddl.Items.Insert(0, new ListItem("Select", "0"));

        }
        public void PopulateEnrollCdn(ref System.Web.UI.WebControls.DropDownList ddl)
        {
            OpenSISWCFServiceStudentFormLayoutClient vmlDL8 = new OpenSISWCFServiceStudentFormLayoutClient();
            ddl.Items.Clear();
            DataSet ds = null;
            ds = vmlDL8.PopulateEnrollCdnSt();
            vmlDL8.Close();
            ddl.DataSource = ds.Tables[0];
            ddl.DataTextField = "enr_cd_nm";
            ddl.DataValueField = "enr_cd_id";
            ddl.DataBind();
            ddl.Items.Insert(0, new ListItem("Select", "0"));

        }

        public void PopulateGenderSearch(ref System.Web.UI.WebControls.DropDownList ddl)
        {
            OpenSISWCFServiceStudentFormLayoutClient vmlDL3 = new OpenSISWCFServiceStudentFormLayoutClient();
            ddl.Items.Clear();
            DataSet ds = null;
            ds = vmlDL3.PopulateGenderSt();
            vmlDL3.Close();
            DynamicTranslation DTL = new DynamicTranslation();
            string langto = System.Web.HttpContext.Current.Session["MLUICulture"].ToString();
            if (System.Web.HttpContext.Current.Session["MLUICulture"].ToString() != "en")
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    string origtext = ds.Tables[0].Rows[i]["gender_nm"].ToString();
                    string trantext = DTL.Translate(origtext, "en", langto);
                    ds.Tables[0].Rows[i]["gender_nm"] = trantext;
                }
            }
            ddl.DataSource = ds.Tables[0];
            ddl.DataTextField = "gender_nm";
            ddl.DataValueField = "gender_id";
            ddl.DataBind();
        }

        public void populatecalender(ref System.Web.UI.WebControls.DropDownList ddl,int SchoolID)
        {
            IopenSISServiceStudentClient vmlDL2 = new IopenSISServiceStudentClient();
            ddl.Items.Clear();
            DataTable ds = null;
            ds = vmlDL2.populatecalenderStudentBusiness(SchoolID);
            ddl.DataSource = ds;
            ddl.DataTextField = "Calender_Name";
            ddl.DataValueField = "Caleder_Id";
            ddl.DataBind();
            ddl.Items.Insert(0, new ListItem("Select", "0"));

        }
        public void PopulateContactRelationship(ref System.Web.UI.WebControls.DropDownList ddl)
        {
            IopenSISServiceStudentClient vmlDL2 = new IopenSISServiceStudentClient();
            ddl.Items.Clear();
            DataTable ds = null;
            ds = vmlDL2.PopulateContactRelationshipStudentBusiness();
            ddl.DataSource = ds;
            ddl.DataTextField = "person_stu_rel_type_nm";
            ddl.DataValueField = "person_rel_id";
            ddl.DataBind();
            ddl.Items.Insert(0, new ListItem("Select", "0"));

        }
        public void PopulateYesNo(ref System.Web.UI.WebControls.RadioButtonList rdb)
        {
            rdb.Items.Clear();

            rdb.Items.Insert(0, new ListItem("Yes", "Y"));
            rdb.Items.Insert(1, new ListItem("No", "N"));
           

        }


        public void PopulateEvaluationType(ref System.Web.UI.WebControls.DropDownList ddl)
        {
            IopenSISServiceStudentClient vmlDL2 = new IopenSISServiceStudentClient();
            ddl.Items.Clear();
            DataTable ds = null;
            ds = vmlDL2.PopulateEvaluationTypeStudentBusiness();

            vmlDL2.Close();
            ddl.DataSource = ds;
            ddl.DataTextField = "evaluation_type_nm";
            ddl.DataValueField = "evaluation_type_id";
            ddl.DataBind();
            ddl.Items.Insert(0, new ListItem("Select", "0"));

        }
        public void PopulateDisabilities(ref System.Web.UI.WebControls.DropDownList ddl)
        {
            IopenSISServiceStudentClient vmlDL2 = new IopenSISServiceStudentClient();
            ddl.Items.Clear();
            DataTable ds = null;
            ds = vmlDL2.PopulateDisabilitiesStudentBusiness();
            vmlDL2.Close();
            ddl.DataSource = ds;
            ddl.DataTextField = "Disability_nm";
            ddl.DataValueField = "Disability_Id";
            ddl.DataBind();
            ddl.Items.Insert(0, new ListItem("Select", "0"));

        }
        public void PopulateGiftedCategory(ref System.Web.UI.WebControls.DropDownList ddl)
        {
            IopenSISServiceStudentClient vmlDL2 = new IopenSISServiceStudentClient();
            ddl.Items.Clear();
            DataTable ds = null;
            ds = vmlDL2.PopulateGiftedCategoryStudentBusiness();
            vmlDL2.Close();
            ddl.DataSource = ds;
            ddl.DataTextField = "Gift_Cat_nm";
            ddl.DataValueField = "Gift_Cat_Id";
            ddl.DataBind();
            ddl.Items.Insert(0, new ListItem("Select", "0"));

        }
        public void PopulateSpecialEduStatus(ref System.Web.UI.WebControls.DropDownList ddl)
        {
            IopenSISServiceStudentClient vmlDL2 = new IopenSISServiceStudentClient();
            ddl.Items.Clear();
            DataTable ds = null;
            ds = vmlDL2.PopulateSpecialEduStatusStudentBusiness();
            vmlDL2.Close();
           
            ddl.DataSource = ds;
            ddl.DataTextField = "Special_Edn_Status_nm";
            ddl.DataValueField = "Special_Edn_Status_Id";
            ddl.DataBind();
            ddl.Items.Insert(0, new ListItem("Select", "0"));

        }
        public void PopulateSpecialEduExistStatus(ref System.Web.UI.WebControls.DropDownList ddl)
        {
            IopenSISServiceStudentClient vmlDL2 = new IopenSISServiceStudentClient();
            ddl.Items.Clear();
            DataTable ds = null;
            ds = vmlDL2.PopulateSpecialEduExistStatusStudentBusiness();
            vmlDL2.Close();
           
            ddl.DataSource = ds;
            ddl.DataTextField = "Specl_Edn_Exist_Stat_nm";
            ddl.DataValueField = "Specl_Edn_Exist_Stat_id";
            ddl.DataBind();
            ddl.Items.Insert(0, new ListItem("Select", "0"));

        }

        public void populateReligion(ref System.Web.UI.WebControls.DropDownList ddl)
        {
            OpenSISWCFServiceStudentFormLayoutClient vmlDL7 = new OpenSISWCFServiceStudentFormLayoutClient();
            ddl.Items.Clear();
            DataSet ds = null;
            ds = vmlDL7.populateReligionSt();
            vmlDL7.Close();
            ddl.DataSource = ds.Tables[0];
            ddl.DataTextField = "Religion_Name";
            ddl.DataValueField = "Religion_Id";
            ddl.DataBind();
            ddl.Items.Insert(0, new ListItem("Select", "0"));

        }


    }
}